<template>
  <div class="timeTable">
    <div>
      <el-button type="primary" @click="goNewSchedule">新建日程</el-button>
      <el-button v-if="!showUnfold" @click="showUnfold=true">展开筛选</el-button>
      <el-button v-if="showUnfold" type="info" @click="showUnfold=false">收起筛选</el-button>
    </div>
    <el-collapse-transition>
      <div v-if="showUnfold">
        <div class="search-box">
          <div class="search-list">
            <el-select v-model="searchList.course" placeholder="请选择课程" class="search-item">
              <el-option
                v-for="item in courseOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.courseKnob" placeholder="请选择课节" class="search-item">
              <el-option
                v-for="item in courseKnobOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.class" placeholder="请选择班级" class="search-item">
              <el-option
                v-for="item in classOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.campus" placeholder="请选择校区" class="search-item">
              <el-option
                v-for="item in campusOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <el-button type="primary">搜索</el-button>
        </div>
        <div class="search-box">
          <div class="search-list">
            <el-select v-model="searchList.classRoom" placeholder="请选择教室" class="search-item">
              <el-option
                v-for="item in classRoomOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.teacher" placeholder="请选择教师" class="search-item">
              <el-option
                v-for="item in teacherOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.appoint" placeholder="请选择预约规则" class="search-item">
              <el-option
                v-for="item in appointOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.schedule" placeholder="请选择日程状态" class="search-item">
              <el-option
                v-for="item in scheduleOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </div>
      </div>
    </el-collapse-transition>
    <div class="month-calendar">
      <full-calendar
        :events="events"
        :config="config"
        class="test-fc"
        locale="fr"
        @event-selected="eventClick"
        @day-click="dayClick"
      />
    </div>
  </div>
</template>

<script>
import { FullCalendar } from 'vue-full-calendar'
import 'fullcalendar/dist/fullcalendar.css'
export default {
  components: {
    FullCalendar
  },
  data() {
    return {
      events: [
        { id: '2434', title: '语文作文', start: '2019-08-01T12:30', end: '2019-08-01T13:30' },
        { title: '数学逻辑', start: '2019-08-02T10:20', end: '2019-08-02T11:00', color: 'red' },
        { title: '历史文化', start: '2019-08-03T14:20', end: '2019-08-03T15:20', color: 'green' },
        { title: '英语口语', start: '2019-08-04T16:00', end: '2019-08-04T17:00', color: 'orange', editable: true },
        { title: '物理能量守恒', start: '2019-08-05T18:40', end: '2019-08-05T19:20' }
      ],
      config: {
        firstDay: 1,
        locale: 'zh-cn',
        // defaultView: 'mounth',
        defaultView: 'month',

        height: 'auto',
        header: {
          left: 'agendaDay,agendaWeek,month',
          center: 'title',
          right: 'prev,today,next'
        },
        /* agenda 模式 */
        allDaySlot: false,
        slotLabelFormat: 'H:mm', // axisFormat 'H(:mm)'
        slotLabelInterval: 1,
        slotDuration: '00:30:00',
        minTime: '8:00',
        maxTime: '21:00',
        // 事件是否可编辑，可编辑是指可以移动, 改变大小等。
        editable: true,
        /* 设置按钮文字 */
        buttonText: {
          today: '今天',
          day: '日',
          week: '周',
          month: '月'
        }
      },
      showUnfold: false,
      searchList: {
        course: '',
        courseKnob: '',
        class: '',
        campus: '',
        classRoom: '',
        teacher: '',
        appoint: '',
        schedule: ''
      },
      courseOptions: [],
      courseKnobOptions: [],
      classOptions: [],
      campusOptions: [],
      classRoomOptions: [],
      teacherOptions: [],
      appointOptions: [
        {
          value: '需预约',
          label: '需预约'
        },
        {
          value: '无需预约',
          label: '无需预约'
        }
      ],
      scheduleOptions: [
        {
          value: '未授课',
          label: '未授课'
        },
        {
          value: '授课中',
          label: '授课中'
        },
        {
          value: '已授课',
          label: '已授课'
        }
      ]
    }
  },
  methods: {
    goNewSchedule() {
      this.$router.push({ name: 'Newschedule' })
    },
    eventClick(date, jsEvent, view) {
      console.log('eventClick', date, jsEvent, view)
    },
    dayClick(date, jsEvent, view) {
      console.log('dayClick', date, jsEvent, view)
    },
  }
}
</script>

<style lang="scss" scoped>
.timeTable {
  .search-box {
    margin: 20px 0;
    display: flex;
    .search-list {
      margin-right: 20px;
      color: #353535;
      .search-item {
        width: 280px;
      }
    }
  }
  .month-calendar {
    margin: 20px 0;
    /deep/.fc-unthemed {
      // max-width: 80%;
      // margin: 0 auto;
      .fc-head {
        height: 40px;
        line-height: 40px;
        background-color: rgb(138, 210, 252);
      }
      .fc-event, .fc-event-dot {
        background-color: #22bc6e;
      }
    }
  }
}
</style>
